<template>
  <div class="home-1">
    <div class="home-1-content">
      <van-swipe lazy-render :show-indicators="false">
        <van-swipe-item v-for="(item, index) in images" :key="index">
          <img :src="item.img" class="home-1-img" />
        </van-swipe-item>
      </van-swipe>

      <div class="homes-lfti">
        <div class="xins-1">
          {{
            flag
              ? store.user.realName
              : `**${store?.user.realName.charAt(store.user.realName.length - 1)}`
          }}<img :src="flag ? k : b" @click="toggleFlag" />
        </div>
        <div class="xu-1" @click="qadd">
          {{ fieldValue }}<van-icon name="arrow-down" />
        </div>
      </div>
      <div class="homes-xue" @click="xueadd">学在农林</div>
      <div class="home-1-co1">
        <CpRadioBtn title="常用服务" @cadd="zjadd"></CpRadioBtn>

        <div class="home-1-co3">
          <div
            class="home-1-co4"
            v-for="(item, index) in arr"
            :key="index"
            @click="add"
          >
            <img :src="item.img" class="imgs-1" />
            <div class="home-1-co5">{{ item.name }}</div>
          </div>
        </div>
      </div>
    </div>
    <!-- 内容 -->
    <div class="home-12">
      <div class="gon-1">
        <div class="gon-1-1" @click="gadd"></div>
        <div class="gon-1-2">学校隆重召开校友会第二届第二次会员代表大会</div>
      </div>
      <div class="home-banner">
        <van-swipe indicator-color="#fff">
          <van-swipe-item>
            <img src="@/assets/ad.png" alt="" />
          </van-swipe-item>
          <van-swipe-item>
            <img src="@/assets/ad.png" alt="" />
          </van-swipe-item>
        </van-swipe>
      </div>
      <div class="xue-1">
        <div class="xue-12 pg-1" @click="addurl">
          <div class="x-1">学校简历</div>
          <div class="x-2">校园风采</div>
        </div>
        <div class="xue-12 pg-2" @click="zaddurl">
          <div class="x-1">专业介绍</div>
          <div class="x-2">专业亮点</div>
        </div>
      </div>
      <div class="tuijian-1">
        <CpRadioBtn title="推荐服务" @cadd="zjadd"></CpRadioBtn>

        <div class="t-2">
          <img src="../../assets/home/ic_jsjdjzscx.png" class="img-1s" />
          <div class="te-1">
            <div class="te-2">计算机等级证书查询</div>
            <div class="te-3">计算机证书在线查</div>
          </div>
        </div>
        <div class="t-2">
          <img src="../../assets/home/ic_jyfw.png" class="img-1s" />
          <div class="te-1">
            <div class="te-2">主标题</div>
            <div class="te-3">这里是副标题</div>
          </div>
        </div>
      </div>
    </div>
  
  <van-popup v-model="showPicker" round position="bottom">
  <van-picker
    show-toolbar
    :columns="columns"
    @cancel="showPicker = false"
    @confirm="onConfirm"
  />
</van-popup>
  </div>
</template>

<script>

import z1 from '@/assets/home/ic_zxt.png'
import z2 from '@/assets/home/ic_zlqn.png'
import z3 from '@/assets/home/ic_rczp.png'
import z4 from '@/assets/home/ic_yslndx.png'
import z5 from '@/assets/home/ic_jyfw.png'
import z6 from '@/assets/home/ic_xszz.png'
import z7 from '@/assets/home/ic_fkjx.png'
import z8 from '@/assets/home/ic_xjzgrzt.png'
import k from '@/assets/home/ic_view.png'
import b from '@/assets/home/ic_hide.png'
import slu from '@/assets/home/pic_bg.png'
import { getComtoken } from '@/api/user'
import {  mapState } from 'vuex'
import  CpRadioBtn from "@/components/CpRadioBtn.vue"
export default {
  components: {
    CpRadioBtn,
  },
  data () {
    return {
      arr: [
        { name: '浙学通', img: z1 },
        { name: '浙里青年', img: z2 },
        { name: '人才招聘', img: z3 },
        { name: '云上老年大学', img: z4 },
        { name: '就业服务', img: z5 },
        { name: '学生资助', img: z6 },
        { name: '访客进校', img: z7 },
        { name: '教职工入职...', img: z8 }
      ],
      k,
      b,
      images: [
        { img: slu },
        { img: slu },
        { img: slu },
        { img: slu }
      ],
     
      showPicker: false,
      columns: [
        { text: '学生', value: '1' },
        { text: '教师', value: '2' },
        { text: '家长', value: '3' },
        { text: '社会学习者', value: '3' }
      ],
      fieldValue: '请选择',
      flag: false,
      uobjs:{
        1:"学生",
        2:"教师",
        3:"家长",
        4:'社会'
      }
    }
  },
  created () {
 this.fieldValue=this.uobjs[this.store.user.userType]
    // this.getlist()
  },
  computed: {
    ...mapState({
      store: state => state.user.user,
      authToken: state => state.comtoken.token
    })
  },
  methods: {
    async getlist () {
      const res = await getComtoken()
    },
    add () {
      this.$router.push('/Nestedpage')
    },
    gadd () {
      this.$router.push('/Announcement')
    },
    addurl () {
      window.location.href = 'https://www.zafu.edu.cn/xqzl/xxgk.htm'
    },
    zaddurl () {
      window.location.href = 'https://zs.zafu.edu.cn/zyjs.htm'
    },
    zjadd () {
      this.$router.push('/notify')
    },
    qadd () {
      this.showPicker = true
      
    },
    yonx(){
      // eslint-disable-next-line no-undef
      // ZWJSBridge.openLink({
      //   url: `https://mapi.zjzwfw.gov.cn/web/mgop/gov-open/zj/2002202546/reserved/index.html?appId=${this.store.user.appId}&token=${this.authToken}&areaCode=330101&isIframe=true&redirectUrl=/childrenList`
      // }).then((res) => {
      //   console.log(res, '浙理办')
      // })
    },
    xueadd () {
      // eslint-disable-next-line no-undef
      // ZWJSBridge.openLink({
      //   url: `https://mapi.zjzwfw.gov.cn/web/mgop/gov-open/zj/2002182803/reserved/index.html#/subplatform?siteId=4133010341&token=${this.authToken}`
      // }).then((res) => {
      //   console.log(res, '浙理办')
      // })
    },
    onConfirm (value) {
      this.showPicker = false
      this.fieldValue = value.text
      if(value.text==='学生'){
        this.yonx()
        }
    },
    toggleFlag () {
      this.flag = !this.flag
    }
  },
 
}
</script>

<style lang="scss" scoped>
.home-1 {
  padding-bottom: 57px;
  width: 100%;
  height: 100%;
  background: #f7f7f7;
  box-sizing: border-box;
}
.home-1-content {
  width: 100%;
  height: 190px;
  position: relative;

  margin-bottom: 162px;
}
.home-1-img {
  width: 100%;
  height: 190px;
}
.home-1-co1 {
  position: absolute;
  top: 160px;
  left: 11px;
  width: 352px;
  height: 193px;
  background: #ffffff;
  border-radius: 8px;
  padding: 11px;
  border: 1px solid #e5e5e5;
  box-sizing: border-box;
}
.homes-lfti {
  position: absolute;
  top: 126px;
  left: 10px;
  display: flex;
}
.xu-1 {
  width: 100px;
  height: 22px;
  text-align: center;
  border-radius: 10px;
  opacity: 0.8;
  border: 1px solid #e5e5e5;
  background-color: #564616;
  color: #d7d6d0;
}
.xins-1 {
  width: 80px;
  display: flex;
  align-items: center;
  justify-content: space-around;
  color: #fff;
}
.homes-xue {
  width: 92px;
  height: 28px;
  color: #fff;
  padding: 2px;
  line-height: 26px;
  text-align: right;
  position: absolute;
  top: 122px;
  right: 0px;
  background-image: url('../../assets/home/switch.png');
  background-size: 100% 100%;
  background-repeat: no-repeat;
  box-sizing: border-box;
}
.home-1-co2 {
  width: 100%;
  height: 24px;
  font-weight: 500;
  font-size: 15px;
  color: #333333;
}
.home-1-co3 {
  width: 100%;
  height: 148px;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
}
.home-1-co4 {
  width: 80px;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.home-1-co5 {
  width: 100%;
  text-align: center;
  font-weight: 400;
  font-size: 13px;
  color: #333333;
}
.imgs-1 {
  width: 40px;
  height: 40px;
}
.home-12 {
  width: 100%;
  padding: 11px 11px 0;
  box-sizing: border-box;
}
.gon-1 {
  width: 100%;
  height: 31px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.gon-1-1 {
  width: 67px;
  height: 31px;
  background-image: url('@/assets/home/tag_home_notice.png');
  background-size: 100% 100%;
  background-repeat: no-repeat;
}
.gon-1-2 {
  width: 270px;
  height: 19px;
  white-space: nowrap; /* 防止文本换行 */
  overflow: hidden; /* 溢出隐藏 */
  text-overflow: ellipsis; /* 使用省略号显示截断的文本 */
}
.home-banner {
  width: 100%;
  height: 100px;
  box-sizing: border-box;
  margin-top: 11px;
  img {
    width: 100%;
    height: 100%;
  }
}
.xue-1 {
  width: 100%;
  height: 94px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 11px;
}
.xue-12 {
  width: 170px;
  height: 94px;
  border: 1px solid #e5e5e5;
  padding: 11px;
  border-radius: 8px;
  box-sizing: border-box;
}
.pg-1 {
  background-image: url('../../assets/home/bg_campusintroduction.png');
  background-size: 100% 100%;
  background-repeat: no-repeat;
}
.pg-2 {
  background-image: url('../../assets/home/bg_professionalintroduction.png');
  background-size: 100% 100%;
  background-repeat: no-repeat;
}
.x-1 {
  font-weight: 500;
  font-size: 15px;
  color: #333333;
}
.x-2 {
  font-weight: 400;
  font-size: 11px;
  color: #777777;
}
.tuijian-1 {
  width: 100%;
  height: 210px;
  background: #ffffff;
  border-radius: 8px;
  margin-top: 11px;
  padding: 11px;
  border: 1px solid #e5e5e5;
  box-sizing: border-box;
}
.t-1 {
  width: 100%;
  height: 44px;
  font-weight: 500;
  font-size: 15px;
  color: #333333;
}
.t-2 {
  width: 100%;
  height: 73px;
  background: #f5f6fa;
  border-radius: 6px;
  display: flex;
  align-items: center;
}
.te-1 {
  margin-left: 5px;
}
.te-2 {
  font-weight: 400;
  font-size: 15px;
  color: #333333;
}
.te-3 {
  font-weight: 400;
  font-size: 12px;
  color: #777777;
}
.img-1s {
  width: 40px;
  height: 40px;
}
iframe {
  width: 100%;
  height: 100%; /* 确保 iframe 高度撑满父级 */
  border: none; /* 如果需要，移除 iframe 的边框 */
}
</style>
